package router

import (
	"jgt-oper/src/api"
	"jgt-oper/src/context"

	"github.com/facebookgo/inject"
	"github.com/teambition/gear"
)

// APIUserMap 注册路由映射
func APIUserMap(g *inject.Graph, r *gear.Router) {
	a := new(api.User)
	err := g.Provide(&inject.Object{Value: a})
	if err != nil {
		panic(err)
	}

	r.Get("/discover", context.WrapContext(a.QueryDiscoverMenu))
	r.Get("/users/my_function", context.WrapContext(a.QueryMyFunctionMenu))
	r.Get("/public/users/:id", context.WrapContext(a.Get))
	r.Post("/users/register", context.WrapContext(a.UpdateRegister))
	r.Post("/users/function", context.WrapContext(a.SaveCommonFunction))
	r.Post("/users/auth", context.WrapContext(a.Auth))
	r.Post("/users/writeoff", context.WrapContext(a.WriteOff))
	r.Post("/users/setting", context.WrapContext(a.SaveSetting))
}
